using System;
using System.Data.Entity.ModelConfiguration;
using System.Data.Common;
using System.Data.Entity;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using HISModels.Entities;

namespace HISModels.Mapping
{
	public class SysSequenceNumberMap : EntityTypeConfiguration<SysSequenceNumber>
	{
		public SysSequenceNumberMap()
		{
			// Primary Key
			this.HasKey(t => t.Id);

			// Properties
			this.Property(t => t.CodeFormat)
				.HasMaxLength(50);
				
			this.Property(t => t.DescValue)
				.HasMaxLength(255);
				
			// Table & Column Mappings
			this.ToTable("SysSequenceNumbers");
			this.Property(t => t.Id).HasColumnName("Id");
			this.Property(t => t.NumberValue).HasColumnName("NumberValue");
			this.Property(t => t.DateValue).HasColumnName("DateValue");
			this.Property(t => t.CodeFormat).HasColumnName("CodeFormat");
			this.Property(t => t.DescValue).HasColumnName("DescValue");
			this.Property(t => t.TransactionCodeId).HasColumnName("TransactionCodeId");
			this.Property(t => t.HuLobRelId).HasColumnName("HuLobRelId");

			// Relationships
			this.HasOptional(t => t.HuLobRel)
				.WithMany(t => t.SysSequenceNumbers)
				.HasForeignKey(d => d.HuLobRelId);
				
			this.HasOptional(t => t.RefDocumentType)
				.WithMany(t => t.SysSequenceNumbers)
				.HasForeignKey(d => d.TransactionCodeId);
				
		}
	}
}

